<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.14.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>DM-CtrlH7-BF-DevProgram: C:/Users/ASUS/Desktop/dm-ctrlH7-balance-9025test/modules/motor/DJImotor/dji_motor.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="50x5.png"/></td>
  <td id="projectalign">
   <div id="projectname">DM-CtrlH7-BF-DevProgram<span id="projectnumber">&#160;beta 0.1</span>
   </div>
   <div id="projectbrief">C.ONE Studio Damiao Development Board Framework</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.14.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search/",'.html');
</script>
<script type="text/javascript">
$(function() { codefold.init(); });
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search',true);
  $(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(function(){initNavTree('dji__motor_8h_source.html','',''); });
</script>
<div id="container">
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div class="header">
  <div class="headertitle"><div class="title">dji_motor.h</div></div>
</div><!--header-->
<div class="contents">
<a href="dji__motor_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span></div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno">   14</span> </div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span><span class="preprocessor">#ifndef DJI_MOTOR_H</span></div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno">   16</span><span class="preprocessor">#define DJI_MOTOR_H</span></div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno">   17</span> </div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno">   18</span><span class="preprocessor">#include &quot;bsp_can.h&quot;</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno">   19</span><span class="preprocessor">#include &quot;<a class="code" href="controller_8h.html">controller.h</a>&quot;</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno">   20</span><span class="preprocessor">#include &quot;<a class="code" href="motor__def_8h.html">motor_def.h</a>&quot;</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span><span class="preprocessor">#include &quot;stdint.h&quot;</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span><span class="preprocessor">#include &quot;daemon.h&quot;</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span> </div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno">   24</span><span class="preprocessor">#define DJI_MOTOR_CNT 12</span></div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span> </div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span><span class="comment">/* 滤波系数设置为1的时候即关闭滤波 */</span></div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno">   27</span><span class="preprocessor">#define SPEED_SMOOTH_COEF 0.85f      </span><span class="comment">// 最好大于0.85</span></div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno">   28</span><span class="preprocessor">#define CURRENT_SMOOTH_COEF 0.9f     </span><span class="comment">// 必须大于0.9</span></div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno">   29</span><span class="preprocessor">#define ECD_ANGLE_COEF_DJI 0.043945f </span><span class="comment">// (360/8192),将编码器值转化为角度制</span></div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno">   30</span> </div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno">   31</span><span class="comment">/* DJI电机CAN反馈信息*/</span></div>
<div class="foldopen" id="foldopen00032" data-start="{" data-end="};">
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"><a class="line" href="struct_d_j_i___motor___measure__s.html">   32</a></span><span class="keyword">typedef</span> <span class="keyword">struct</span></div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno">   33</span>{</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span>    uint16_t last_ecd;        <span class="comment">// 上一次读取的编码器值</span></div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno">   35</span>    uint16_t ecd;             <span class="comment">// 0-8191,刻度总共有8192格</span></div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span>    <span class="keywordtype">float</span> angle_single_round; <span class="comment">// 单圈角度</span></div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span>    <span class="keywordtype">float</span> speed_aps;          <span class="comment">// 角速度,单位为:度/秒</span></div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno">   38</span>    int16_t real_current;     <span class="comment">// 实际电流</span></div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span>    uint8_t temperature;      <span class="comment">// 温度 Celsius</span></div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span> </div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span>    <span class="keywordtype">float</span> total_angle;   <span class="comment">// 总角度,注意方向</span></div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno">   42</span>    int32_t total_round; <span class="comment">// 总圈数,注意方向</span></div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno">   43</span>} <a class="code hl_struct" href="struct_d_j_i___motor___measure__s.html">DJI_Motor_Measure_s</a>;</div>
</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno">   44</span></div>
<div class="foldopen" id="foldopen00049" data-start="{" data-end="};">
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"><a class="line" href="struct_d_j_i_motor_instance.html">   49</a></span><span class="keyword">typedef</span> <span class="keyword">struct</span></div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno">   50</span>{</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno">   51</span>    <a class="code hl_struct" href="struct_d_j_i___motor___measure__s.html">DJI_Motor_Measure_s</a> measure;            <span class="comment">// 电机测量值</span></div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span>    <a class="code hl_struct" href="struct_motor___control___setting__s.html">Motor_Control_Setting_s</a> motor_settings; <span class="comment">// 电机设置</span></div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno">   53</span>    <a class="code hl_struct" href="struct_motor___controller__s.html">Motor_Controller_s</a> motor_controller;    <span class="comment">// 电机控制器</span></div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno">   54</span> </div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno">   55</span>    CANInstance *motor_can_instance; <span class="comment">// 电机CAN实例</span></div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno">   56</span>    <span class="comment">// 分组发送设置</span></div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno">   57</span>    uint8_t sender_group;</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno">   58</span>    uint8_t message_num;</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno">   59</span> </div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno">   60</span>    Motor_Type_e motor_type;        <span class="comment">// 电机类型</span></div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno">   61</span>    Motor_Working_Type_e stop_flag; <span class="comment">// 启停标志</span></div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span> </div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span>    DaemonInstance* daemon;</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span>    uint32_t feed_cnt;</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span>    <span class="keywordtype">float</span> dt;</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno">   66</span>} <a class="code hl_struct" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a>;</div>
</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno">   67</span></div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno">   84</span><a class="code hl_struct" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> *<a class="code hl_function" href="dji__motor_8h.html#ae6a2dbd0d46fc7d80c6e2339aad09969">DJIMotorInit</a>(<a class="code hl_struct" href="struct_motor___init___config__s.html">Motor_Init_Config_s</a> *config);</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno">   85</span></div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span><span class="keywordtype">void</span> <a class="code hl_function" href="dji__motor_8h.html#afc682af85b4e84a7a74d01097cf738e5">DJIMotorSetRef</a>(<a class="code hl_struct" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> *motor, <span class="keywordtype">float</span> ref);</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span></div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno">  102</span><span class="keywordtype">void</span> <a class="code hl_function" href="dji__motor_8h.html#af949d3574538d826035110bf7e05c2f8">DJIMotorChangeFeed</a>(<a class="code hl_struct" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> *motor, <a class="code hl_enumeration" href="motor__def_8h.html#a306d656c63a2d986e7aff57a0526395d">Closeloop_Type_e</a> loop, Feedback_Source_e type);</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno">  103</span></div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno">  107</span><span class="keywordtype">void</span> <a class="code hl_function" href="dji__motor_8h.html#a550e8d4dd6e722e66552563550191c65">DJIMotorControl</a>();</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno">  108</span></div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno">  113</span><span class="keywordtype">void</span> <a class="code hl_function" href="dji__motor_8h.html#a51d98dd3aee5e6e9530db1eb31f43642">DJIMotorStop</a>(<a class="code hl_struct" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> *motor);</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno">  114</span></div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno">  120</span><span class="keywordtype">void</span> <a class="code hl_function" href="dji__motor_8h.html#a7488031c4d093a41e2eaf8dd3881365b">DJIMotorEnable</a>(<a class="code hl_struct" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> *motor);</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno">  121</span></div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno">  128</span><span class="keywordtype">void</span> <a class="code hl_function" href="dji__motor_8h.html#adbffe8a35fe1da0ed6c36227ce30f1cd">DJIMotorOuterLoop</a>(<a class="code hl_struct" href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a> *motor, <a class="code hl_enumeration" href="motor__def_8h.html#a306d656c63a2d986e7aff57a0526395d">Closeloop_Type_e</a> outer_loop);</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno">  129</span> </div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno">  130</span><span class="preprocessor">#endif </span><span class="comment">// !DJI_MOTOR_H</span></div>
<div class="ttc" id="acontroller_8h_html"><div class="ttname"><a href="controller_8h.html">controller.h</a></div></div>
<div class="ttc" id="adji__motor_8h_html_a51d98dd3aee5e6e9530db1eb31f43642"><div class="ttname"><a href="dji__motor_8h.html#a51d98dd3aee5e6e9530db1eb31f43642">DJIMotorStop</a></div><div class="ttdeci">void DJIMotorStop(DJIMotorInstance *motor)</div><div class="ttdoc">停止电机,注意不是将设定值设为零,而是直接给电机发送的电流值置零</div><div class="ttdef"><b>Definition</b> dji_motor.c:210</div></div>
<div class="ttc" id="adji__motor_8h_html_a550e8d4dd6e722e66552563550191c65"><div class="ttname"><a href="dji__motor_8h.html#a550e8d4dd6e722e66552563550191c65">DJIMotorControl</a></div><div class="ttdeci">void DJIMotorControl()</div><div class="ttdoc">该函数被motor_task调用运行在rtos上,motor_stask内通过osDelay()确定控制频率</div><div class="ttdef"><b>Definition</b> dji_motor.c:233</div></div>
<div class="ttc" id="adji__motor_8h_html_a7488031c4d093a41e2eaf8dd3881365b"><div class="ttname"><a href="dji__motor_8h.html#a7488031c4d093a41e2eaf8dd3881365b">DJIMotorEnable</a></div><div class="ttdeci">void DJIMotorEnable(DJIMotorInstance *motor)</div><div class="ttdoc">启动电机,此时电机会响应设定值 初始化时不需要此函数,因为stop_flag的默认值为0</div><div class="ttdef"><b>Definition</b> dji_motor.c:215</div></div>
<div class="ttc" id="adji__motor_8h_html_adbffe8a35fe1da0ed6c36227ce30f1cd"><div class="ttname"><a href="dji__motor_8h.html#adbffe8a35fe1da0ed6c36227ce30f1cd">DJIMotorOuterLoop</a></div><div class="ttdeci">void DJIMotorOuterLoop(DJIMotorInstance *motor, Closeloop_Type_e outer_loop)</div><div class="ttdoc">修改电机闭环目标(外层闭环)</div><div class="ttdef"><b>Definition</b> dji_motor.c:221</div></div>
<div class="ttc" id="adji__motor_8h_html_ae6a2dbd0d46fc7d80c6e2339aad09969"><div class="ttname"><a href="dji__motor_8h.html#ae6a2dbd0d46fc7d80c6e2339aad09969">DJIMotorInit</a></div><div class="ttdeci">DJIMotorInstance * DJIMotorInit(Motor_Init_Config_s *config)</div><div class="ttdoc">调用此函数注册一个DJI智能电机,需要传递较多的初始化参数,请在application初始化的时候调用此函数 推荐传参时像标准库一样构造initStructure然后传入此函数....</div><div class="ttdef"><b>Definition</b> dji_motor.c:159</div></div>
<div class="ttc" id="adji__motor_8h_html_af949d3574538d826035110bf7e05c2f8"><div class="ttname"><a href="dji__motor_8h.html#af949d3574538d826035110bf7e05c2f8">DJIMotorChangeFeed</a></div><div class="ttdeci">void DJIMotorChangeFeed(DJIMotorInstance *motor, Closeloop_Type_e loop, Feedback_Source_e type)</div><div class="ttdoc">切换反馈的目标来源,如将角速度和角度的来源换为IMU(小陀螺模式常用)</div><div class="ttdef"><b>Definition</b> dji_motor.c:200</div></div>
<div class="ttc" id="adji__motor_8h_html_afc682af85b4e84a7a74d01097cf738e5"><div class="ttname"><a href="dji__motor_8h.html#afc682af85b4e84a7a74d01097cf738e5">DJIMotorSetRef</a></div><div class="ttdeci">void DJIMotorSetRef(DJIMotorInstance *motor, float ref)</div><div class="ttdoc">被application层的应用调用,给电机设定参考值. 对于应用,可以将电机视为传递函数为1的设备,不需要关心底层的闭环</div><div class="ttdef"><b>Definition</b> dji_motor.c:227</div></div>
<div class="ttc" id="amotor__def_8h_html"><div class="ttname"><a href="motor__def_8h.html">motor_def.h</a></div><div class="ttdoc">电机通用的数据结构定义</div></div>
<div class="ttc" id="amotor__def_8h_html_a306d656c63a2d986e7aff57a0526395d"><div class="ttname"><a href="motor__def_8h.html#a306d656c63a2d986e7aff57a0526395d">Closeloop_Type_e</a></div><div class="ttdeci">Closeloop_Type_e</div><div class="ttdoc">闭环类型,如果需要多个闭环,则使用或运算 例如需要速度环和电流环: CURRENT_LOOP|SPEED_LOOP</div><div class="ttdef"><b>Definition</b> motor_def.h:25</div></div>
<div class="ttc" id="astruct_d_j_i___motor___measure__s_html"><div class="ttname"><a href="struct_d_j_i___motor___measure__s.html">DJI_Motor_Measure_s</a></div><div class="ttdef"><b>Definition</b> dji_motor.h:33</div></div>
<div class="ttc" id="astruct_d_j_i_motor_instance_html"><div class="ttname"><a href="struct_d_j_i_motor_instance.html">DJIMotorInstance</a></div><div class="ttdoc">DJI intelligent motor typedef.</div><div class="ttdef"><b>Definition</b> dji_motor.h:50</div></div>
<div class="ttc" id="astruct_motor___control___setting__s_html"><div class="ttname"><a href="struct_motor___control___setting__s.html">Motor_Control_Setting_s</a></div><div class="ttdef"><b>Definition</b> motor_def.h:73</div></div>
<div class="ttc" id="astruct_motor___controller__s_html"><div class="ttname"><a href="struct_motor___controller__s.html">Motor_Controller_s</a></div><div class="ttdef"><b>Definition</b> motor_def.h:87</div></div>
<div class="ttc" id="astruct_motor___init___config__s_html"><div class="ttname"><a href="struct_motor___init___config__s.html">Motor_Init_Config_s</a></div><div class="ttdef"><b>Definition</b> motor_def.h:131</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
</div><!-- container -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a href="dir_e05d7e2b1ecd646af5bb94391405f3b5.html">modules</a></li><li class="navelem"><a href="dir_e1337f9400e8caa7f7e380800549fa55.html">motor</a></li><li class="navelem"><a href="dir_f89843c4372d768f2c54a2320c5ec8ec.html">DJImotor</a></li><li class="navelem"><a href="dji__motor_8h.html">dji_motor.h</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0 </li>
  </ul>
</div>
</body>
</html>
